<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LibTools: H:/project/LibTools/src/time/CCounter.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LibTools
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.16 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','搜索');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_798ee6f4f5cd9c6410c07a649b7662ec.html">time</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">CCounter.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_c_counter_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">//CCounter.h head file</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; </div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#ifndef _CCOUNTER_H_</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#define _CCOUNTER_H_</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;../tools/ShareApi.h&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160; </div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<a class="code" href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; </div>
<div class="line"><a name="l00012"></a><span class="lineno"><a class="line" href="class_c_counter.html">   12</a></span>&#160;<span class="keyword">class </span><a class="code" href="tools_8h.html#a64152c8b939d1ce06c7c5cb6c97b62f8">LIBTOOLS</a> <a class="code" href="class_c_counter.html">CCounter</a></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;{</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="class_c_counter.html#ab83c6f9600beb5686747493da731a04c">   15</a></span>&#160;    <a class="code" href="class_c_counter.html#ab83c6f9600beb5686747493da731a04c">CCounter</a>() {</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;        <a class="code" href="namespace_share_api.html#aa3a32d171616bf6ce986acb93ce88d30">QueryPerformanceFrequency</a>(&amp;_fre);</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;        Begin(); </div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;    }</div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="class_c_counter.html#a238890e46379c3ac72d6b684cb097ce1">   20</a></span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="class_c_counter.html#a238890e46379c3ac72d6b684cb097ce1">NowCSec</a>(){</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        <a class="code" href="union___l_a_r_g_e___i_n_t_e_g_e_r.html">LARGE_INTEGER</a> Now;</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;        <a class="code" href="namespace_share_api.html#a52ea835c01d56aaf225ab37baacf7dd6">LibTools::ShareApi::QueryPerformanceCounter</a>(&amp;Now);</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;        <span class="keywordflow">return</span> ((Now.<a class="code" href="union___l_a_r_g_e___i_n_t_e_g_e_r.html#a34beb9c05c3a2982d57fc450cc934ae3">QuadPart</a>-m_StartTime.QuadPart)*1000000) / _fre.QuadPart;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    } </div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="class_c_counter.html#a6bbb55ad2a2b36b8b1faeaed4d1bb3b0">   26</a></span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="class_c_counter.html#a6bbb55ad2a2b36b8b1faeaed4d1bb3b0">NowMSec</a>(){</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;        <a class="code" href="union___l_a_r_g_e___i_n_t_e_g_e_r.html">LARGE_INTEGER</a> Now;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        <a class="code" href="namespace_share_api.html#a52ea835c01d56aaf225ab37baacf7dd6">LibTools::ShareApi::QueryPerformanceCounter</a>(&amp;Now);</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;        <span class="keywordflow">return</span> ((Now.<a class="code" href="union___l_a_r_g_e___i_n_t_e_g_e_r.html#a34beb9c05c3a2982d57fc450cc934ae3">QuadPart</a>-m_StartTime.QuadPart)*1000) / _fre.QuadPart;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;    }</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="class_c_counter.html#ad0359d01f5ee5bc736bbc0dd39ff3ea7">   32</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="class_c_counter.html#ad0359d01f5ee5bc736bbc0dd39ff3ea7">Begin</a>(){</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;        <a class="code" href="namespace_share_api.html#a52ea835c01d56aaf225ab37baacf7dd6">LibTools::ShareApi::QueryPerformanceCounter</a>(&amp;_StartTime);</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    }       </div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="class_c_counter.html#ab93be1db99d08205f86dddb455fd2684">   36</a></span>&#160;    <a class="code" href="union___l_a_r_g_e___i_n_t_e_g_e_r.html">LARGE_INTEGER</a> <a class="code" href="class_c_counter.html#ab93be1db99d08205f86dddb455fd2684">_fre</a>;      </div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="class_c_counter.html#a3ea9d3f4502ef6f6e391a6bac36b8975">   37</a></span>&#160;    <a class="code" href="union___l_a_r_g_e___i_n_t_e_g_e_r.html">LARGE_INTEGER</a> <a class="code" href="class_c_counter.html#a3ea9d3f4502ef6f6e391a6bac36b8975">_StartTime</a>;    </div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;}; </div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160; </div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<a class="code" href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_c_counter_html_ad0359d01f5ee5bc736bbc0dd39ff3ea7"><div class="ttname"><a href="class_c_counter.html#ad0359d01f5ee5bc736bbc0dd39ff3ea7">CCounter::Begin</a></div><div class="ttdeci">void Begin()</div><div class="ttdef"><b>Definition:</b> <a href="_c_counter_8h_source.html#l00032">CCounter.h:32</a></div></div>
<div class="ttc" id="anamespace_share_api_html_aa3a32d171616bf6ce986acb93ce88d30"><div class="ttname"><a href="namespace_share_api.html#aa3a32d171616bf6ce986acb93ce88d30">ShareApi::QueryPerformanceFrequency</a></div><div class="ttdeci">LIBTOOLS BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency)</div><div class="ttdoc">获取cup时间频率函数(linux下该函数无效)</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l01850">ShareApi.cpp:1850</a></div></div>
<div class="ttc" id="aclass_c_counter_html"><div class="ttname"><a href="class_c_counter.html">CCounter</a></div><div class="ttdoc">高精度计时器</div><div class="ttdef"><b>Definition:</b> <a href="_c_counter_8h_source.html#l00012">CCounter.h:12</a></div></div>
<div class="ttc" id="aclass_c_counter_html_ab93be1db99d08205f86dddb455fd2684"><div class="ttname"><a href="class_c_counter.html#ab93be1db99d08205f86dddb455fd2684">CCounter::_fre</a></div><div class="ttdeci">LARGE_INTEGER _fre</div><div class="ttdoc">高精度下计数器的频率</div><div class="ttdef"><b>Definition:</b> <a href="_c_counter_8h_source.html#l00036">CCounter.h:36</a></div></div>
<div class="ttc" id="aunion___l_a_r_g_e___i_n_t_e_g_e_r_html_a34beb9c05c3a2982d57fc450cc934ae3"><div class="ttname"><a href="union___l_a_r_g_e___i_n_t_e_g_e_r.html#a34beb9c05c3a2982d57fc450cc934ae3">_LARGE_INTEGER::QuadPart</a></div><div class="ttdeci">LONGLONG QuadPart</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00211">tools.h:211</a></div></div>
<div class="ttc" id="atools_8h_html_a201ce692c9dca6599e5c12d00167419b"><div class="ttname"><a href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div><div class="ttdeci">#define DEF_BEG_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00036">tools.h:36</a></div></div>
<div class="ttc" id="aclass_c_counter_html_a6bbb55ad2a2b36b8b1faeaed4d1bb3b0"><div class="ttname"><a href="class_c_counter.html#a6bbb55ad2a2b36b8b1faeaed4d1bb3b0">CCounter::NowMSec</a></div><div class="ttdeci">long long NowMSec()</div><div class="ttdoc">毫秒</div><div class="ttdef"><b>Definition:</b> <a href="_c_counter_8h_source.html#l00026">CCounter.h:26</a></div></div>
<div class="ttc" id="atools_8h_html_a64152c8b939d1ce06c7c5cb6c97b62f8"><div class="ttname"><a href="tools_8h.html#a64152c8b939d1ce06c7c5cb6c97b62f8">LIBTOOLS</a></div><div class="ttdeci">#define LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00095">tools.h:95</a></div></div>
<div class="ttc" id="aclass_c_counter_html_a238890e46379c3ac72d6b684cb097ce1"><div class="ttname"><a href="class_c_counter.html#a238890e46379c3ac72d6b684cb097ce1">CCounter::NowCSec</a></div><div class="ttdeci">long long NowCSec()</div><div class="ttdoc">微秒</div><div class="ttdef"><b>Definition:</b> <a href="_c_counter_8h_source.html#l00020">CCounter.h:20</a></div></div>
<div class="ttc" id="atools_8h_html_ac909db71799bb22cb7d636a34cd785e4"><div class="ttname"><a href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div><div class="ttdeci">#define DEF_END_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00038">tools.h:38</a></div></div>
<div class="ttc" id="aunion___l_a_r_g_e___i_n_t_e_g_e_r_html"><div class="ttname"><a href="union___l_a_r_g_e___i_n_t_e_g_e_r.html">_LARGE_INTEGER</a></div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00202">tools.h:202</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a52ea835c01d56aaf225ab37baacf7dd6"><div class="ttname"><a href="namespace_share_api.html#a52ea835c01d56aaf225ab37baacf7dd6">ShareApi::QueryPerformanceCounter</a></div><div class="ttdeci">LIBTOOLS BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)</div><div class="ttdoc">获取CPU的执行时间</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l01860">ShareApi.cpp:1860</a></div></div>
<div class="ttc" id="aclass_c_counter_html_ab83c6f9600beb5686747493da731a04c"><div class="ttname"><a href="class_c_counter.html#ab83c6f9600beb5686747493da731a04c">CCounter::CCounter</a></div><div class="ttdeci">CCounter()</div><div class="ttdef"><b>Definition:</b> <a href="_c_counter_8h_source.html#l00015">CCounter.h:15</a></div></div>
<div class="ttc" id="aclass_c_counter_html_a3ea9d3f4502ef6f6e391a6bac36b8975"><div class="ttname"><a href="class_c_counter.html#a3ea9d3f4502ef6f6e391a6bac36b8975">CCounter::_StartTime</a></div><div class="ttdeci">LARGE_INTEGER _StartTime</div><div class="ttdoc">高精度下的开始时间值</div><div class="ttdef"><b>Definition:</b> <a href="_c_counter_8h_source.html#l00037">CCounter.h:37</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
